from django.db import models
from libs import ModelMixin, human_datetime
from apps.account.models import User

types = (
    ('tencent', '腾讯云'),
    ('physical', '物理机房'),
    ('other', '其他')
)


class Idc(models.Model, ModelMixin):
    name = models.CharField(max_length=50)
    key = models.CharField(max_length=50)
    type = models.CharField(choices=types, null=True, max_length=50)
    secretid = models.CharField(max_length=50, null=True)
    secretkey = models.CharField(max_length=50, null=True)
    desc = models.CharField(max_length=255, null=True)

    created_at = models.CharField(max_length=20, default=human_datetime)
    created_by = models.ForeignKey(User, models.PROTECT, related_name='+')
    deleted_at = models.CharField(max_length=20, null=True)
    deleted_by = models.ForeignKey(User, models.PROTECT, related_name='+', null=True)

    def __repr__(self):
        return '<Idc %r>' % self.name

    class Meta:
        db_table = 'idcs'
        ordering = ('-id',)
